<?php
 /*************************************************\
    TV-Program
    Version: 2.5
    Author: Dmitri M. Furmanoff
    E-mail: furik@mail.ru
    \*************************************************/

    /*************************************************\
    Компонент: Телепрограммы
    Версия: 2.5
    Автор: Дмитрий Фурманов
    E-mail: furik@mail.ru
    \*************************************************/

defined( '_VALID_MOS' ) or die( 'Доступ к файлу запрещен.' );



class HTML_TVChannels {



  function showChannels( $option, &$rows, &$clist, &$slist, &$search, &$pageNav ,$pathlogo) {
global $database,$mosConfig_absolute_path;

//read lastcheck.tmp

if(file_exists($mosConfig_absolute_path."/administrator/components/com_tv/lastcheck.tmp"))
   {
    $check=file($mosConfig_absolute_path."/administrator/components/com_tv/lastcheck.tmp");
    if(isset($check[0]))
        $last = $check[0]; 
    else
        $last = "";
    if(isset($check[1]))
        $next = $check[1]; 
    else
        $next = 0;
    if(isset($check[2]))
        $p_count = $check[2]; 
    else
        $p_count = 0;
   }
else
  {
    $last = "";
    $next = 0;
	$p_count=0;
  }
?>
<form action="index2.php" method="post" name="adminForm1">
<table width="50%" cellspacing="0" cellpadding="0">
<tr>
<td align="right">Последнее обновление:</td><td><?php echo $last;?></td>
</tr>
<tr>
<td align="right">Количество программ:</td><td><?php echo $p_count;?></td>
</tr>
<?php if($next) {?>
<tr>
<td align="right">Следующее обновление:</td><td><?php echo date("d.m.Y",$next);?></td>
</tr>
<?php } ?>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Очистить" />
<input type="hidden" name="option" value="<?php echo $option;?>" />
<input type="hidden" name="task" value="delcheck" />
</td>
</tr>
</table>
</form>


    <form action="index2.php" method="post" name="adminForm">

    <table cellpadding="4" cellspacing="0" border="0" width="100%">

    <tr>

      <td width="100%" class="sectionname">
      
      </td>

      <td nowrap="nowrap">На страницу<br>
        <?php echo $pageNav->writeLimitBox(); ?>

      </td>

      <td>Поиск:<br>
<input type="text" name="search" value="<?php echo $search;?>" class="inputbox" onChange="document.adminForm.submit();" />

      </td>

    </tr>
    </table>


    <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">

      <tr>

        <th width="20">

          <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />

        </th>

        <th class="title" width="65%">Название</th>
        <th width="5%">Логотип</th>
        <th width="5%">Программ</th>
        <th width="5%">Смещение</th>
        <th width="5%">В модуле</th>
        <th width="5%">Опубликовано</th>
        <th colspan="2" nowrap="nowrap"><div align="center">Реорганизовать</div></th>
      </tr>

      <?php
        $i=0;
        $k = 0;

      for ($i=0, $n=count( $rows ); $i < $n; $i++) {

        $row = &$rows[$i];
        $task = $row->published ? 'unpublish' : 'publish';
        $img = $row->published ? 'tick.png' : 'publish_x.png';
        $mtask = $row->module ? 'unpublishmodule' : 'publishmodule';
        $mimg = $row->module ? 'tick.png' : 'publish_x.png';
               


        ?>

      <tr class="<?php echo "row$k"; ?>">
        <td>
          <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->cid; ?>" onclick="isChecked(this.checked);" />

        </td>

        <td>

          <a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')">

            <?php echo $row->channelname; ?>

          </a>

        </td>
         <td>
            <?php if($row->channellogo!=="")
                  echo "<img src='$pathlogo/$row->channellogo' height='20'>";
                else
                  echo "<img src='images/blank.png' height='20'>";
              ?>
          </td>
         
          <td>
            <?php echo $row->pcount; ?>
          </td>

         <td align='center'>
<?php                  echo $row->timeoffset;              ?>
          </td>

        <?php

        echo "<td align='center'>";
?>
        <a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>','<?php echo $mtask;?>')"><img src="images/<?php echo $mimg;?>" width="12" height="12" border="0" alt="" /></a>
<?php
        echo "</td>";

        ?>


        <?php

        echo "<td align='center'>";
?>
        <a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>','<?php echo $task;?>')"><img src="images/<?php echo $img;?>" width="12" height="12" border="0" alt="" /></a>
</td>
 <td>
        <?php		if ($i > 0 || ($i+$pageNav->limitstart > 0)) { ?>
        <div align="center"><a href="#reorder" onclick="return listItemTask('cb<?php echo $i;?>','orderupch')">
          <img src="images/uparrow.png" width="12" height="12" border="0" alt="Выше">
          </a>
          <?php		} else { echo "&nbsp;"; } ?>
        </div></td>
      <td>
        <?php		if ($i < $n-1 || $i+$pageNav->limitstart < $pageNav->total-1) { ?>
        <div align="center"><a href="#reorder" onclick="return listItemTask('cb<?php echo $i;?>','orderdownch')">
          <img src="images/downarrow.png" width="12" height="12" border="0" alt="Ниже">
          </a>
          <?php		} else { echo "&nbsp;"; } ?>
        </div></td>

        

        <?php $k = 1 - $k;

        echo "</tr>";

       } ?>

      <tr>

        <th align="center" colspan="9">

          <?php echo $pageNav->writePagesLinks(); ?></th>

      </tr>

      <tr>

        <td align="center" colspan="9">

          <?php echo $pageNav->writePagesCounter(); ?></td>

      </tr>

    </table>

    <input type="hidden" name="option" value="<?php echo $option;?>" />

    <input type="hidden" name="task" value="" />

    <input type="hidden" name="boxchecked" value="0" />

    </form>


<?php


  }



function editChannel( $option, &$row, &$clist, &$logolist, $pathlogo, $orderlist) {
global $my;
?>

    <script language="javascript" type="text/javascript">

    function submitbutton(pressbutton) {

      var form = document.adminForm;

      if (pressbutton == 'cancel') {

        submitform( pressbutton );

        return;

      }



      // do field validation

      if (form.channelname.value == ""){

        alert( "Введите название канала" );

      }  else {

        submitform( pressbutton );

      }

    }

    </script>

    <table cellpadding="4" cellspacing="0" border="0" width="100%">

    <tr>



    </tr>

  </table>

    <table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">

    <form action="index2.php" method="post" name="adminForm" id="adminForm">

      <tr>

        <td width="20%" align="right">Название канала (в БД)</td>

        <td width="80%">

          <input class="inputbox" type="text" name="channelid" size="39" maxlength="100" value="<?php echo htmlspecialchars($row->channelid, ENT_QUOTES );?>" />

        </td>
      </tr>


      <tr>

        <td width="20%" align="right">Название канала (для отображения)</td>

        <td width="80%">

          <input class="inputbox" type="text" name="channelname" size="39" maxlength="100" value="<?php echo htmlspecialchars($row->channelname, ENT_QUOTES );?>" />

        </td>
      </tr>

      <tr>

        <td width="20%" align="right">Смещение по времени для канала:</td>

        <td width="80%">

          <input class="inputbox" type="text" name="timeoffset" size="10" maxlength="10" value="<?php echo htmlspecialchars($row->timeoffset, ENT_QUOTES );?>" />

        </td>

      </tr>

	  <tr>
        <td valign="top" align="right" width="150">Список логотипов:</td>
        <td width="320" valign="top">
          <?php echo $logolist; ?>
        </td>
	  </tr>	
<tr>
<td valign="top" >Очередность</td>
<td nowrap ><?php echo $orderlist?></td>
</tr>

    </table>



    <input type="hidden" name="cid" value="<?php echo $row->cid; ?>" />

    <input type="hidden" name="option" value="<?php echo $option;?>" />

    <input type="hidden" name="task" value="" />

    </form>

    <p>

    <table cellpadding="4" cellspacing="1" border="0" class="adminform">
      <tr><td>
<table width="600" align="left">
<tr>
        <td valign="top" align="center" width="200">
        <b>Логотип:</b><br />
        <script language="javascript" type="text/javascript">
          if (document.forms[0].channellogo.options.value!=''){
            jsimg='<?php echo "..$pathlogo/"; ?>' + getSelectedValue( 'adminForm', 'channellogo' );
          } else {
            jsimg='../images/M_images/blank.png';
          }
          document.write('<img src=' + jsimg + ' name="imagelib" width="120" height="90" border="1" alt="Предпросмотр логотипа" />');
          </script>
        </td>
</tr>
</table>
<?php

  }


  }

?>
